/**
 * Created by zhaofei on 2017/5/2.
 */
//public class FristTestServlet {
//}
import java.io.*;
import java.io.IOException;
import java.util.Enumeration;
import com.meituan.Student;
import com.meituan.StudentMapper;
import org.apache.ibatis.session.SqlSession;
import java.util.Enumeration;

import javax.servlet.*;
import javax.servlet.http.*;

/**
 * Created by zhaofei on 2017/5/2.
 */

public class FristTestServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        Enumeration en = request.getParameterNames();
        SqlSession session = GetSession.getSqlSession();
        StudentMapper studentMapper = null;
        try {
            studentMapper = session.getMapper(StudentMapper.class);
            while (en.hasMoreElements()) {
                String name = (String)en.nextElement();
                String temp = request.getParameter(name);
                int tempInt = Integer.parseInt(temp);
                Student student = (Student)studentMapper.selectStudent(tempInt);
                out.println(student);
            }
        } catch (Exception e){
            e.printStackTrace();
        } finally {
            if (session != null) {
                session.close();
            }
        }

        /*

        */



    }
}


